<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>Cadastro de clientes</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="bootstrap-theme.css" type="text/css" rel="stylesheet"/>
        <link href="bootstrap.min.css" type="text/css" rel="stylesheet"/>
        <script type="text/javascript" src="jquery.js"></script>
        <script language="javascript">
            
           function iniciaAjax() {
                var objetoAjax = false;
                if (window.XMLHttpRequest) {
                    objetoAjax = new XMLHttpRequest();
                } else if (window.ActiveXObject) {
                    try {
                        objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
                    } catch(e) {
                        try {
                            objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch(ex) {
                            objetoAjax = false;
                        }
                    }
                }
                return objetoAjax;
            }
            
    var ini = iniciaAjax();
    
            function getRadioValor(name){
                var rads = document.getElementsByName(name).value;
  
                for(var i = 0; i < rads.length; i++){
                    if(rads[i].checked){
                        return rads[i].value;
                    }
  
                }
  
                return null;
            }
            
            function QuemSomos (){
                location.href="http://localhost:8083/teste-loja/QuemSomos"
               
            }
            
            function Deletar(op1,cpf){
                var PrimaryKey = cpf;
                var op1 = op1;
                var url = "http://localhost:8083/teste-loja/GerenciaCliente?op1="+op1+"&PrimaryKey="+PrimaryKey;
                ini.open("GET",url,true);
                ini.onreadystatechange = callback;
                ini.send(null); 
            }
            
            function cadastrar(x){
            var op1 = x;      
            if(op1 === 1){
                
                var nome = document.getElementById("nome").value;
                var endereço = document.getElementById("endereço").value;
                var cpf = document.getElementById("cpf").value;
                var sexo = document.getElementById("sexo").value;
                var idade = document.getElementById("idade").value;
                
                var url = "http://localhost:8083/teste-loja/GerenciaCliente?nome="+nome+"&endereço="+endereço+"&cpf="+cpf+"&sexo="+sexo+"&idade="+idade+"&op1="+op1;
            } else{
                var url = "http://localhost:8083/teste-loja/GerenciaCliente?op1="+op1;
            } 
            
                ini.open("GET",url,true);
                ini.onreadystatechange = callback;
                ini.send(null);   
            }

              function callback(){
                if (ini.readyState === 4){
                    if (ini.status === 200){ 
                        document.getElementById("respostaServidor").innerHTML = ini.responseText;                    
                    }
                }
            }
            
        </script>
    </head>
    <body>
        <nav class="navbar navbar-inverse" role="navigation">
            <ul class="nav nav-tabs">
                <li role="presentation"><a href="#">Home</a></li>
                <li role="presentation" onclick="QuemSomos()"><a href="">Quem Somos</a></li>
                <li role="presentation"><a href="#">Contatos</a></li>
            </ul>
        </nav>
        <form>
            <table border="1" width="1" class="table table-striped">
                <caption>    
                    <strong> <h2 style="font-family: Georgia" >CADASTRO DE CLIENTES</h2> </strong>
                </caption>
                    <tr>
                        <td>NOME</td>
                        <td><input type="text" name="nome" id="nome" value="" /></td>
                    </tr>
                    <tr>
                        <td>ENDEREÇO</td>
                        <td><input type="text" name="endereço" id="endereço" value="" /></td>
                    </tr>
                    <tr>
                        <td>CPF</td>
                        <td><input type="text" name="cpf" id="cpf" value="" /></td>
                    </tr>
                    <tr>
                        <td>SEXO</td>
                        <td>
                            MASCULINO: <input type="radio" name="sexo" id="sexo" value="MASCULINO" />
                            FEMININO: <input type="radio" name="sexo" id="sexo" value="FEMININO" />
                        </td>
                        
                    </tr>
                    <tr>
                        <td>IDADE</td>
                        <td><input type="text" name="idade" id="idade" value="" /></td>
                    </tr>
                    <tr>
                        <td> 
                         
                            <input type="button" value="cadastrar" onclick="cadastrar(1)"/> 
                            
                        </td>
                        
                        <td> <input type="button" value="consultar" onclick="cadastrar(2)" /> </td>
                    </tr>
            </table>
        </form>
        
        <div id="respostaServidor">
            Receber.
        </div>
    </body>
</html>
